package com.xinhe.web.reposity;

import com.xinhe.web.entity.UserRole;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface UserRoleRepository extends JpaRepository<UserRole, Long> {
    @Query(value = "select aur.* from auth_user_role aur where aur.removed = 0 and aur.f_user_id =?1", nativeQuery = true)
    List<UserRole> findByUserId(Long userId);

    @Modifying
    @Query(value = "update auth_user_role set removed = 1 where f_user_id = ?1", nativeQuery = true)
    void deleteByUserId(Long userId);
}
